package com.jin.flashsaled.RabbitMQ;

import com.jin.flashsaled.entity.User;
import com.jin.flashsaled.result.BuyMessage;
import com.jin.flashsaled.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RabbitRecive {
    @Autowired
    private IOrderService orderService;



    @RabbitListener(queues = "seckillQueue")//监听队列
    public void recive(BuyMessage buyMessager)
    {
        Long userId=buyMessager.getUserID();
        Long goodId=buyMessager.getGoodID();
        User user=new User();
        user.setId(userId);
        orderService.buy(user,goodId);



    }
}
